﻿using Microsoft.Xna.Framework;

namespace RoboTrocity.Code.ObjectStates {
	class ClimbingState : EntityState {

        public Ladder Target { get; set; }

		public ClimbingState(Entity entity, Sprite newSprite)
			: base(entity, newSprite) {
		}

        public override void MoveUp()
        {
            if (attachedEntity.Position.Y > Target.Bounds.Top)
                attachedEntity.Position.Y-=3;

        }
        
        public override void MoveDown()
        {
            if (attachedEntity.Position.Y < Target.Bounds.Bottom)
                attachedEntity.Position.Y+=3;
            else
            {
                attachedEntity.HasGravity = true;
                attachedEntity.CurrentState = attachedEntity.getState(typeof(StandState));
                (attachedEntity.CurrentState as EntityState).Jump();
            }

        }

		public override void Jump() {
		    attachedEntity.HasGravity = true;
            attachedEntity.CurrentState = attachedEntity.getState(typeof (StandState));
            (attachedEntity.CurrentState as EntityState).Jump();
		}

		public override void MoveLeft() {
			attachedEntity.FacingLeft = true;
		}

		public override void MoveRight() {
			attachedEntity.FacingLeft = false;
		}

		public override void Update(float elapsed) {
			//no gravity
			attachedEntity.Position += attachedEntity.Velocity;
			attachedEntity.Velocity = Vector2.Zero;
			attachedEntity.HasGravity = false;
		}
	}
}
